#include "BD_SDLHeaders.h"
#include "BD_Event.h"
#include "BD_EventMouse.h"
#include "BD_EventKey.h"

using namespace BnD;

BD_Event* BD_Event::GetEvent()
{
	static BD_Event* s_event = new BD_Event();
	static BD_EventMouse* s_eventMouse = new BD_EventMouse();	
	static BD_EventKey* s_eventKey = new BD_EventKey();

	static SDL_Event* s_sdlEvent = new SDL_Event();

	s_event->m_event = s_sdlEvent;
	s_eventMouse->m_event = s_sdlEvent;
	s_eventKey->m_event = s_sdlEvent;

	if(SDL_PollEvent(s_sdlEvent) != 0)
	{
		switch(s_sdlEvent->type)
		{
		case SDL_MOUSEBUTTONDOWN:
		case SDL_MOUSEBUTTONUP:
		case SDL_MOUSEMOTION:
			return s_eventMouse;
		default:
			return s_event;
		}
	}
	return NULL;
}


BD_EventType BD_Event::GetType()
{
	return (BD_EventType)m_event->type;
}